package fr.xgouchet.wedding.client.view;

import com.google.gwt.event.dom.client.HasClickHandlers;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.DialogBox;
import com.google.gwt.user.client.ui.HorizontalPanel;
import com.google.gwt.user.client.ui.Label;
import com.google.gwt.user.client.ui.VerticalPanel;

import fr.xgouchet.wedding.client.i18n.Constants;

/**
 * Widget to display a confirm box (Yes / No)
 * 
 * @author x.gouchet
 * 
 */
public class ConfirmDialogBox extends DialogBox {

	/**
	 * Constructor
	 * 
	 * @param caption
	 *            the dialog box Caption
	 * @param question
	 *            the dialog box question
	 */
	public ConfirmDialogBox(String caption, String question) {
		// Set the dialog box's caption.
		setText(caption);
		setModal(true);

		// create widgets
		mYesButton = new Button(Constants.I18N.buttonYes());
		mNoButton = new Button(Constants.I18N.buttonNo());
		Label msg = new Label(question);

		// create Panels
		VerticalPanel main = new VerticalPanel();
		HorizontalPanel buttons = new HorizontalPanel();

		// assemble panels
		buttons.add(mYesButton);
		buttons.add(mNoButton);
		main.add(msg);
		main.add(buttons);

		// add panel to dialog box
		add(main);
		center();
	}

	/**
	 * @return the yes widget
	 */
	public HasClickHandlers getYesButton() {
		return mYesButton;
	}

	/**
	 * @return the no widget
	 */
	public HasClickHandlers getNoButton() {
		return mNoButton;
	}

	/** Yes button */
	private Button mYesButton;

	/** No button */
	private Button mNoButton;

}
